<template>
	<view>
		<!-- 时间显示 -->
		<view v-if="shortTime" class="flex text-light-muted align-center justify-center my-2">
			{{shortTime}}
		</view>
		<!-- 聊天列表 -->
		<view class="flex px-2 my-2"
		:style="isSelf ? 'flex-direction: row-reverse': ''">
			<image :src="item.avatar" style="height: 90rpx;width: 80rpx;"
			class="rounded-circle"></image>
			<view class="flex align-center mx-2 bg-light rounded px-2 font-md" 
			style="max-width: 400rpx;height: 102rpx;border-radius: 20rpx;"
			>{{item.data}}</view>
		</view>
	</view>
</template>

<script>
	// 用户本人id
	const uid = 1;
	import $T from '@/common/time.js';
	export default {
		props:{
			item:Object,
			index:Number,
			preTime: [Number, String]
		},
		computed:{
			// 判断是否是本人
			isSelf() {
				return uid === this.item.user_id
			},
			shortTime() {
				return $T.getChatTime(this.item.created_time, this.preTime)
			}
		}
	}
</script>

<style>
</style>
